<template>
  <div>
    <div>
      <el-container>
        <el-aside :width="asideWidth" style="min-height: 100vh; background-color: #001529">

          <div style="height: 60px; color: white; display: flex; align-items: center; justify-content: center">
            <img src="@/assets/yuan.png" alt="" style="width: 40px; height: 40px">
            <span class="logo-title" v-show="!isCollapse">商家版</span>
          </div>
          <el-menu :collapse="isCollapse" :collapse-transition="false" router background-color="#001529"
                   text-color="rgba(255,255,255,0.65)" active-text-color="#fff" style="border: none"
                   :default-active="$route.path">

            <el-menu-item index="/business/businessHome">
              <i class="el-icon-s-home"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item index="/business/hotelApplication">
              <template slot="title">
                <i class="el-icon-s-opportunity"></i>
                <span slot="title">酒店申请</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/business/pointsApplication" v-if="Status">
              <template slot="title">
                <i class="el-icon-s-flag"></i>
                <span slot="title">活动申请</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/business/roomDetail" v-if="Status">
              <i class="el-icon-s-shop"></i>
              <span slot="title">线下住房</span>
            </el-menu-item>
            <el-submenu index="2" v-if="Status">
              <template slot="title">
                <i class="el-icon-menu"></i>
                <span slot="title">酒店管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/business/hotelHome">酒店首页</el-menu-item>
                <el-menu-item index="/business/room">房间管理</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="3" v-if="Status">
              <template slot="title">
                <i class="el-icon-s-data"></i>
                <span slot="title">订单管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/business/online">线上订单处理</el-menu-item>
                <el-menu-item index="/business/offline">线下订单处理</el-menu-item>
                <el-menu-item index="/business/recordOrder">历史订单</el-menu-item>
                <el-menu-item index="/business/evaluate">用户评论</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="5" v-if="Status">
              <template slot="title">
                <i class="el-icon-s-marketing"></i>
                <span slot="title">统计</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/business/dailyIncome">酒店日收入</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-menu-item @click="logout">
              <i class="el-icon-s-grid"></i>
              <span slot="title">退出登录</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-container>
          <el-header>
            <i :class="collapseIcon" style="font-size: 26px;margin-right: -8px" @click="handleCollapse"></i>
            <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px">
              <el-breadcrumb-item :to="{ path: '/business/businessHome' }">主页</el-breadcrumb-item>
              <el-breadcrumb-item :to="{ path: $route.path }">{{ $route.meta.name }}</el-breadcrumb-item>
            </el-breadcrumb>
            <div
                style="flex: 1;width: 0;display: flex;align-items: center;justify-content: flex-end;margin-right: 30px">
            </div>
          </el-header>
          <el-main> <!--main界面-->
            <div>
              <router-view/>
            </div>
          </el-main>
        </el-container>
      </el-container>
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: 'business',
  data() {
    return {
      isCollapse: false,  // 不收缩
      asideWidth: '200px',//侧边栏宽
      collapseIcon: 'el-icon-s-fold',
      user: JSON.parse(localStorage.getItem('user') || '{}'),
      url: '',
      hotel: [],
      hotelData: {},
      hotel_id: null,
      urls: [],
      Status: false,
    }
  },
  created() { //页面加载完之后触发
    this.load_business_id()
    this.Status = false
  },
  methods: {
    load_business_id() {
      this.$request.post('/hotel_search/', {
        "business_id": this.user.id,
      }).then(res => {
        if (res.code === '200') {
          this.hotel = res.data.hotel_list;
          const length = this.hotel.length;
          this.hotel_id = this.hotel[length - 1].id;
          this.hotelData = this.hotel[length - 1]
          console.log("yyttgg", this.hotelData.status)
          if (this.hotelData.status === "已通过") {
            this.Status = true
            console.log("yyttgg", this.Status)
          }
        } else if (res.code === '501') {
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    updateUser(user) { //获取子组件传过来的数据 更新当前的数据
      this.user = user;
    },
    logout() {
      this.$router.push('/userHome')
      localStorage.removeItem('user')//清除当前的token和用户数据
      this.$message.success('退出成功')
    },
    handleFull() {
      document.documentElement.requestFullscreen()
    },
    handleCollapse() {
      this.isCollapse = !this.isCollapse
      this.asideWidth = this.isCollapse ? '64px' : '200px'
      this.collapseIcon = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'
    },
  }
}
</script>

<style>
.el-submenu__title {
  height: 40px !important;
  line-height: 40px !important;
  padding: 0 25px !important;
  transition: color 0s;
}

.el-menu-item {
  min-width: 0 !important;
  width: calc(100% - 10px);
  margin: 5px;
  height: 40px !important;
  line-height: 40px !important;
  border-radius: 5px;
}

.el-menu--inline {
  background-color: #000c17 !important;
}

.el-menu--inline .el-menu-item {
  background-color: #000c17 !important;
  padding-left: 49px !important;
}

.el-menu-item:hover, .el-submenu__title:hover {
  color: #fff !important;
}

.el-submenu__title:hover i {
  color: #fff !important;
}

.el-menu-item:hover i {
  color: #fff !important;
}

.el-menu-item.is-active {
  background-color: #1890ff !important;
  border-radius: 5px !important;
  width: calc(100% - 8px);
  margin-left: 4px;
}


.el-menu-item {
  height: 40px !important;
  line-height: 40px !important;
}

.el-submenu__title {
  height: 40px !important;
  line-height: 40px !important;
}

.el-submenu .el-menu-item {
  min-width: 0 !important;
}

.el-menu--inline .el-menu-item.is-active {
  padding-left: 45px !important;
}

/*.el-submenu__icon-arrow {  下拉小箭头的位置设置   */
/*  margin-top: -5px;*/
/*}*/

.el-aside {
  transition: width .3s;
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
}

.logo-title {
  margin-left: 5px;
  font-size: 20px;
  transition: all .3s; /* 0.3s */
}

.el-header {
  box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
  display: flex;
  align-items: center;
}

.custom-button {
  border: none;
}

.custom-button:hover {
  background-color: #ffffff;
}

.custom-button:active {
  color: #606266;
}

.custom-button:focus:not(:active) {
  background-color: #ffffff; /* 设置鼠标悬停时的背景颜色为白色 */
  color: #606266;
}

.text_color {
  color: #606266
}

.text_color:hover {
  color: #409EFF;
}

.logout-item {

}

.logout-item i {
  margin-right: 0 !important;
}
</style>